Next | Prev | Up | Top | Contents | Index

I/O and Memory Space Initialization

In the example below, e_space array contains the iospace structures that are used to map in the card's address space. There are two steps in this process: allocating a PIO map and then mapping the requested bus space address into a kernel address.

On the Indigo2 the mapping is a fixed mapping, which permanently maps the entire EISA I/O and memory address space into kernel space, but using the piomap() call will allow your driver to remain fully compatible with potential future hardware that uses programmable I/O space map registers like those used for VME on the CHALLENGE and Onyx architectures. (Simplifies porting of the driver to future hardware.)

Note: The device will only respond to the requested memory address range if it has been programmed through software (in the case of an EISA card) or jumpered on the card (in the case of an ISA card). Before actually beginning to program the card after mapping in the I/O space, it is wise to probe for the card's existence by writing and rereading a register located on the card. This allows the driver to recover if the device has been removed from the system since the kernel was built or if the kernel is copied to another system with a different hardware configuration.

Caution: The probe during edtinit() has a bus error handler in place. After this, a bus error ordinarily causes an operating system panic. In the edtinit() for your driver, you must allocate the necessary mapping resources before you actually map the memory address. The mapping resource allocation and mapping calls apply across all of Silicon Graphics bus adapters (i.e., VME). Their structures are defined in <sys/pio.h.>.

piomap_t *pio_mapalloc(uint_t bus, uint_t adap, iospace_t
                       iospace, int flag, char *name)
This routine allocates a handle that specifies a mapping from kernel virtual space to I/O and memory address space. The returned piomap_t handle is used to provide the mapping to the address space through additional PIO access functions.

Currently, the bus and adap arguments must be ADAP_EISA and 0 respectively, because there is only one EISA bus on Indigo2 platforms. The name argument is a string used to identify which device has a particular space mapped.

The actual mapping is returned by:

caddr_t pio_mapaddr(piomap_t *piomap, iopaddr_t io)
This function returns the kernel virtual address that maps to the PIO-mapped I/O space address.

Silicon Graphics also supports a set of routines that allow a driver to operate on an I/O address space that has an allocated piomap, but does not have a kernel virtual address mapped to the I/O space. For example:

void pio_bcopyin(piomap_t *pmap, iopaddr_t io, caddr_t a, 
    int len)
void pio_bcopyout(piomap_t *pmap, iopaddr_t io, caddr_t a, 
    int len)
For a complete specification of the piomap* functions, see <sys/pio.h>.

Note: There is not currently any advantage to using the routines listed above, although they may be useful on future Silicon Graphics platforms.


Next | Prev | Up | Top | Contents | Index